package offer;
//调整数组顺序使奇数位于偶数前面
public class T13 {
    public void reOrderArray(int [] array) {
        int odd = 0;
        int even = 0;
        int temp[] = new  int[array.length];
        for (int i = 0; i < array.length; i++) {
            if ((array[i]&1)==1) even++;
            temp[i]=array[i];
        }
        for (int i = 0; i < array.length; i++) {
            if ((temp[i]&1)==1) {
                array[odd]=temp[i];
                odd++;
            } else {
                array[even]=temp[i];
                even++;
            }
        }
    }
    public static void main ( String[] args) {
        int array[] = new int[]{1,2,3,4,5,6,7,8,9,10};
        new T13().reOrderArray(array);
        for (int i = 0; i < array.length; i++) {
           System.out.println(array[i]);
        }
    }
}
